<script type="text/javascript" src="{$siteURL}/js/CalendarPopup.js"></script>
<script type="text/javascript" src="{$siteURL}/js/PopupWindow.js"></script>
<script type="text/javascript" src="{$siteURL}/js/AnchorPosition.js"></script>
<script type="text/javascript">
{literal}
function changeDate(y,m,d)
{
	document.getElementById('lessenplannenblok').dateYear.value = y;
	document.getElementById('lessenplannenblok').dateMonth.value = m;
	document.getElementById('lessenplannenblok').dateDay.value = d;
	document.getElementById('lessenplannenblok').submit();
}
{/literal}
</script>
<table class="table_main" border="0">
	<tr>
		<td class="tekst" style="text-align: left">
			<h1>Mijn praktijk</h1>
			<p>&nbsp;</p>
			<form id="lessenplannenblok" method="post" action="{$REQUEST_URI}">
			{if isset($plannenResult) && $plannenResult}
				<h1>De les is ingepland</h1><br/>
			{elseif isset($plannenResult) && !$plannenResult}
				<h1>De les is niet ingepland</h1>
				{if isset($errors) && count($errors) > 0}
				  <ul>
				  {section name="error" loop="$errors"}
				    <li class="error">{$errors[error].message} (#{$errors[error].code})</li>
				  {/section}
				  </ul>
				{/if}
				<br/>
			{/if}
				<h2>Lessen plannen</h2>
				{if $cursussen|@count eq 0}
				<p>Er zijn (nog) geen curssusen gekoppeld. Hierdoor zijn er geen lessen te plannen via Rijlesplanner.</p>
				{else}
				<p>Kies datum, instructeur, cursus en te plannen type.</p>
				<table width="800">
					<tr>
						<td width="300">
							<table border="0">
								<tr>
									<td style="vertical-align: top; padding-top:5px;width:60px;">Datum: </td>
									<td style="vertical-align: top">
										<p style="vertical-align: top">{$datum|date_format:"%A %e %B %Y"|ucfirst} <button title="datum visueel bewerken" style="height: 24px; width: 24px;" onclick="{literal}cal_.showCalendar('cal_'); return false;{/literal}" name="cal__img"><img src="/images/calendar/agenda.gif" width="16" height="15" alt="" /></button><div id="cal_" style="background-color: white; layer-background-color: white; position: absolute; visibility: hidden; z-index: 999;"></div><script language="JavaScript" type="text/javascript">{literal}var cal_ = new CalendarPopup( "cal_", 0, -123 );cal_.setReturnFunction( "cal__change" );cal_.setWeekStartDay( 1 );function cal__change( y, m, d ){changeDate(y,m,d);}document.write( cal_.getStyles() );{/literal}</script></p>
											<table cellpadding="1" border="0">
												<tr>
													<td>
						    						<input type="button" value=" &lt; Dag " style="width: 60px" onclick="changeDate('{$datePrevYear}','{$datePrevMonth}','{$datePrevDay}');">
						    					</td>
						    					<td>
						    						<input type="button" value="Dag &gt; " style="width: 60px" onclick="changeDate('{$dateNextYear}','{$dateNextMonth}','{$dateNextDay}');">
						    					</td>
						    				</tr>
						    				<tr>
						    					<td>
			    									<input type="button" value=" &lt; Week " style="width: 60px" onclick="changeDate('{$datePrevWeekYear}','{$datePrevWeekMonth}','{$datePrevWeekDay}');">
			    								</td>
			    								<td>	
			    									<input type="button" value="Week &gt; " style="width: 60px" onclick="changeDate('{$dateNextWeekYear}','{$dateNextWeekMonth}','{$dateNextWeekDay}');">
			    								</td>
			    							</tr>
			    						</table>
										<input type="hidden" name="dateYear" value="{$dateYear}" />
										<input type="hidden" name="dateMonth" value="{$dateMonth}" />
										<input type="hidden" name="dateDay" value="{$dateDay}" />
									</td>
								</tr>
							</table>
						</td>
						<td style="padding-top:5px">
							<table border="0">
								<tr>
									<td>Instructeur</td>
									<td>
										<select class="submit4" style="height:25px" name="instructeurId" onchange="document.getElementById('lessenplannenblok').submit();">
											<option value="0">Geen voorkeur</option>
											{section name="instructeur" loop="$instructeurs"}
											<option value="{$instructeurs[instructeur]->getId()}"{if $instructeurs[instructeur]->getId() == $instructeurIdSelected} selected="selected"{/if}>{$instructeurs[instructeur]->getNaam()}</option>
											{/section}
										</select>
									</td>
								</tr>
								<tr>
									<td>Cursus</td>
									<td>
										<select class="submit4" style="height:25px" name="cursusId" onchange="document.getElementById('lessenplannenblok').submit();">
											{section name="cursus" loop="$cursussen"}
											<option value="{$cursussen[cursus]->getId()}"{if $cursussen[cursus]->getId() == $cursusIdSelected} selected="selected"{/if}>{$cursussen[cursus]->getPakketNaam()}</option>
											{/section}
										</select>
									</td>
								</tr>
								<tr>
									<td>Type</td>
									<td>
										<select class="submit4" style="height:25px" name="typeId" onchange="document.getElementById('lessenplannenblok').submit();">
										
											{section name="type" loop="$types"}
											<option value="{$types[type]->Id}"{if $types[type]->Id == $typeIdSelected} selected="selected"{/if}>{$types[type]->Naam} ({$types[type]->Minuten} minuten)</option>
											{/section}
										</select>
										<input type="hidden" name="module" value="{$module}" />
										<input type="hidden" name="action" value="lessenplannenblok" />
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
				{/if}
			</form>
			{if count($reedsgepland) > 0}
			<p>&nbsp;</p>
			<h2>Reeds gepland</h2>
		
				<table cellpadding="5" cellspacing="0" border="1" width="100%" class="body">
					<thead>
						<th></th>
						<th>Datum</th>
						<th>Tijd</th>
						<th>Lestype</th>
						<th>Instructeur</th>
						<th></th>
					</thead>
					<tbody>
						{section name="momentgepland" loop="$reedsgepland"}
						<tr>
							<td>{$smarty.section.momentgepland.index+1}. </td>
							<td>{$reedsgepland[momentgepland]->getStart()|date_format:"%e %B %Y"}</td>
							<td>{$reedsgepland[momentgepland]->getStart()|date_format:"%H:%M"}u - {$reedsgepland[momentgepland]->getStop()|date_format:"%H:%M"}u</td>
							<td>{$reedsgepland[momentgepland]->ItemType->getNaam()|ucfirst}</td>
							<td>{$reedsgepland[momentgepland]->Instructeur->getNaam()|ucfirst}</td>
							<td style="text-align:center">
							{if in_array('annuleer', $reedsgepland[momentgepland]->getActies())}
								<form id="annuleren{$smarty.section.momentgepland.index+1}" method="post" action="{$REQUEST_URI}">
									<input type="hidden" name="itemId" value="{$reedsgepland[momentgepland]->getId()}">
									<input type="hidden" name="cursusId" value="{$cursusIdSelected}">
									<input type="hidden" name="module" value="{$module}" />
									<input type="hidden" name="action" value="praktijkannuleren" />
								</form>
								<input type="button" value="Annuleren!" onclick="if (confirm('Weet je zeker dat je de {$reedsgepland[momentgepland]->ItemType->getNaam()} op {$reedsgepland[momentgepland]->getStart()|date_format:"%e %B %Y"} van {$reedsgepland[momentgepland]->getStart()|date_format:"%H:%M"}u tot {$reedsgepland[momentgepland]->getStop()|date_format:"%H:%M"}u wilt annuleren?'{literal})) { document.getElementById('annuleren{/literal}{$smarty.section.momentgepland.index+1}{literal}').submit(); }{/literal}">
							{/if}
							</td>
						</tr>
						{/section}
					</tbody>
				</table>
			<h4>Praktijkmomenten kunnen tot {$annuleertijd} dag(en) van tevoren worden geannuleerd.</h4>
			<p>De volledige planning kun je vinden bij het <a href="/praktijk/cursusoverzicht">cursusoverzicht</a></p>
			<br>
			{/if}
			<h2>Vrije momenten</h2>
			{if count($beschikbaar) > 0}
				<table cellpadding="5" cellspacing="0" border="1" width="100%" class="body">
					<thead>
						<th></th>
						<th>Datum</th>
						<th>Tijd</th>
						<th>Lestype</th>
						<th>Instructeur</th>
						<th></th>
					</thead>
					<tbody>
						{section name="momentbeschikbaar" loop="$beschikbaar"}
						<tr>
							<td>{$smarty.section.momentbeschikbaar.index+1}. </td>
							<td>{$beschikbaar[momentbeschikbaar]->getStart()|date_format:"%e %B %Y"}</td>
							<td>{$beschikbaar[momentbeschikbaar]->getStart()|date_format:"%H:%M"}u - {$beschikbaar[momentbeschikbaar]->getStop()|date_format:"%H:%M"}u</td>
							<td>{$typeNameSelected|ucfirst}</td>
							<td>{$beschikbaar[momentbeschikbaar]->getInstructeur()}</td>
							<td style="text-align:center">
								<form id="plannen{$smarty.section.momentbeschikbaar.index+1}" method="post" action="{$REQUEST_URI}">
									<input type="hidden" name="cursusId" value="{$cursusIdSelected}">
									<input type="hidden" name="blokId" value="{$beschikbaar[momentbeschikbaar]->getId()}">
									<input type="hidden" name="typeId" value="{$typeIdSelected}">
									<input type="hidden" name="startDateYear" value="{$beschikbaar[momentbeschikbaar]->getStart()|date_format:"%Y"}">
									<input type="hidden" name="startDateMonth" value="{$beschikbaar[momentbeschikbaar]->getStart()|date_format:"%m"}">
									<input type="hidden" name="startDateDay" value="{$beschikbaar[momentbeschikbaar]->getStart()|date_format:"%d"}">
									<input type="hidden" name="module" value="{$module}" />
									<input type="hidden" name="action" value="praktijkplannen" />
								</form>
								<input type="button" value="Plannen!" onclick="if (confirm('Weet je zeker dat je een {$typeNameSelected} in wilt plannen voor de huidige geselecteerde cursus ({$cursusNameSelected}) op {$beschikbaar[momentbeschikbaar]->getStart()|date_format:"%e %B %Y"} van {$beschikbaar[momentbeschikbaar]->getStart()|date_format:"%H:%M"}u tot {$beschikbaar[momentbeschikbaar]->getStop()|date_format:"%H:%M"}u?'{literal})) { document.getElementById('{/literal}plannen{$smarty.section.momentbeschikbaar.index+1}{literal}').submit(); }{/literal}">
							</td>
						</tr>
						{/section}
					</tbody>
				</table>
				<p>&nbsp;</p>
				<h4>Let op: inschrijven gebeurt voor je huidige geselecteerde cursus ({$cursusNameSelected}) met het gekozen type (les, examen, etc.).</h4>
			<p>&nbsp;</p>
			{else}
			<p>Er zijn geen vrije momenten.</p>
			{/if}
			<h4>Praktijkmomenten kunnen tot {$plantijd} dag(en) van tevoren worden ingepland.</h4>
		</td>
	</tr>
</table>
